using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class UNITSCONVERSIONMap : EntityTypeConfiguration<UNITSCONVERSION>
    {
        public UNITSCONVERSIONMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("UNITSCONVERSIONS");
            this.Property(t => t.UOFMORDERS).HasColumnName("UOFMORDERS");
            this.Property(t => t.UOFMSALES).HasColumnName("UOFMSALES");
            this.Property(t => t.FACTOR).HasColumnName("FACTOR");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.PROTECTED).HasColumnName("PROTECTED");

            // Relationships
            this.HasOptional(t => t.UNIT)
                .WithMany(t => t.UNITSCONVERSIONS)
                .HasForeignKey(d => d.UOFMORDERS);
            this.HasOptional(t => t.UNIT1)
                .WithMany(t => t.UNITSCONVERSIONS1)
                .HasForeignKey(d => d.UOFMSALES);

        }
    }
}
